package com.example.utils;

import java.util.ArrayList;
import java.util.List;

/**
 * 前端传递filters过滤字段，将其转为 Integer 数组
 *
 * @author ding
 * @since 2024/7/1
 */
public class FiltersUtils {
    public static List<Integer> getFilters(String statuses) {
        List<Integer> status = new ArrayList<>();
        statuses = statuses.substring(statuses.lastIndexOf("[")+1, statuses.lastIndexOf("]"));
        String[] split = statuses.split(",");
        for (String s : split) {
            //将 “1” -> 1
            s = s.substring(1,2);
            status.add(Integer.valueOf(s));
        }
        return status;
    }
}
